import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param str string字符串 原串
     * @param arg char字符型一维数组 需替换数组
     * @return string字符串
     */
    public static String formatString (String str, char[] arg) {
        // write code here
        StringBuilder stringBuilder = new StringBuilder();
        int argCount = 0;
        for (int i = 0; i < str.length(); i++) {
            if(arg.length <= argCount){
                break;
            }
            char c = str.charAt(i);
            if(c == '%'){
                stringBuilder.append(arg[argCount++]);
                i++;
            }else {
                stringBuilder.append(c);
            }
        }
        while (argCount < arg.length){
            stringBuilder.append(arg[argCount++]);
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        String arr = "A%sC%sE";
        char[] arg = {'B','D','F'};
        System.out.println(formatString(arr,arg));
    }
}